//任务表的增删改查
import { Ajaxurl } from "@/store/defaultData";
//import axios from "axios";
import { axiosType, TaskAddType } from "@/store/interface";
import { instance, addParamIfDefined } from "@/axios/public";
/**
 * 增 - 添加变更数据,返回状态，增加成功或失败
 */

export const addTaskTable = async (data: TaskAddType): Promise<boolean> => {
  const params = new URLSearchParams();
  params.append("action", "add_task_table");
  addParamIfDefined(params, "title", data.title);
  addParamIfDefined(params, "type", data.type);
  addParamIfDefined(params, "reward", data.reward);
  addParamIfDefined(params, "task_time", data.task_time);
  addParamIfDefined(params, "source", data.source);
  try {
    const data = (await instance.post(Ajaxurl, params)) as axiosType;
    console.log(data);
    return true;
  } catch (error) {
    console.log(error);
    return false;
  }
};
